package com.lyc.shopping_mall.mapper;

import com.lyc.shopping_mall.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    // 查询所有用户
    @Select("SELECT * FROM User")
    List<User> getAllUser();

    //根据用户名和密码查询用户
    @Select("SELECT * FROM User WHERE username=#{username} AND userpassword=#{userpassword}")
    User getUserByUsernameAndPassword(String username, String userpassword);

    //新增用户，id自增，成功返回1，失败返回0
    @Insert("INSERT INTO User(username,userpassword,userphone) VALUES(#{username},#{userpassword},#{userphone})")
    Integer addUser(User user);


}
